<template>
  <Panel title="疫情防控" v-bind="$attrs">
    <div class="epidemic-content">
      <div class="item-node">
        <div class="title">防疫检查点</div>
        <div class="img img-point"></div>
        <div class="number check">
          {{ state.epidemicCount }}
        </div>

        <div class="compare">
          <span>较昨日</span>
          <span v-if="isNaN(state.epidemicCountHb)"> -</span>

          <span class="up" v-else-if="state.epidemicCountHb > 0">
            <span class="rising"></span>{{ Math.abs(state.epidemicCountHb || 0) }}%</span
          >
          <span class="down" v-else> <span class="falling"></span>{{ Math.abs(state.epidemicCountHb || 0) }}%</span>
        </div>
      </div>
      <div class="item-node">
        <div class="title">涉疫车辆数</div>
        <div class="img img-car"></div>
        <div class="number car">
          {{ state.epidemicVehicle }}
        </div>

        <div class="compare">
          <span>较昨日</span>
          <span v-if="isNaN(state.epidemicVehicleHb)"> -</span>
          <span class="up" v-else-if="state.epidemicVehicleHb > 0">
            <span class="rising"></span>{{ Math.abs(state.epidemicVehicleHb || 0) }}%</span
          >
          <span class="down" v-else> <span class="falling"></span>{{ Math.abs(state.epidemicVehicleHb || 0) }}%</span>
        </div>
      </div>
    </div>
  </Panel>
</template>

<script>
export default {
  name: 'Epidemic'
}
/**
 * @desc 疫情防控 (一级)
 * @auther 邓清波
 * @date  2022/10/24
 * **/
</script>
<script setup>
import Panel from '../../components/panel'
import epidemicApi from '../../api/epidemic'
import { shallowRef } from 'vue'
import useWatchStore from '@/hooks/useWatchStore'
import useDefaultEmits from '@/hooks/useDefaultEmits'
import { config } from 'process'

useDefaultEmits()
useWatchStore(getData)
const state = shallowRef({})

/**
 * 获取疫情防控统计数
 * */
function getData(argParams) {
  const params = {
    roadType: argParams.roadType,
    province: '32',
    city: argParams.areaCode
  }
  epidemicApi.getEpidemicStatistic(params).then(res => {
    state.value = res.data || {}
  })
}
</script>

<style lang="less" scope>
@import url(../../styles/themes/index.less);

/deep/ .mz-panel-content-main {
  flex-direction: row !important;
  justify-content: space-around;
}

.epidemic-content {
  flex: 1;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: url('../../assets/images/epidemic/epidemic-bg.png') no-repeat;
  background-size: 100%;
  cursor: pointer;

  .item-node {
    width: 100px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;

    .title {
      font-size: 14px;
      color: #333333;
      line-height: 26px;
    }

    .img {
      width: 100%;
      height: 72px;
    }

    .img-point {
      background: url('../../assets/images/epidemic/epidemic-point-count.png') no-repeat;
      background-size: 100%;
    }

    .img-car {
      background: url('../../assets/images/epidemic/epidemic-car-count.png') no-repeat;
      background-size: 100%;
    }

    .check {
      color: @primary-color;
      font-size: 30px;
      height: 22px;
      line-height: 22px;
    }

    .car {
      color: #fe3636;
      font-size: 30px;
      height: 22px;
      line-height: 22px;
    }
  }

  .compare {
    height: 12px;
  }
}

.up {
  color: #f53f3f;
}

.down {
  color: #19bc69;
}

.rising {
  display: inline-block;
  width: 0.08rem;
  height: 100%;
  margin: 0 1px 0 5px;
  background: url(../../assets/images/rising.png) no-repeat;
  background-size: 100%;
}

.falling {
  display: inline-block;
  width: 0.08rem;
  height: 100%;
  margin: 0 1px 0 5px;
  background: url(../../assets/images/falling.png) no-repeat;
  background-size: 100%;
}
</style>
